<!DOCTYPE html>
<html>
<body>

<h1>我的时钟</h1>

<p id="demo"></p>

<script>
function getTime() {
  var d = new Date();
  var h = d.getHours();
  var m = d.getMinutes();
  var s = d.getSeconds();
  var time = h + ":" + m + ":" + s;
  document.getElementById("demo").innerHTML = time;
}

setInterval(getTime, 1000); // 每隔1秒获取一次时间
</script> 

</body>
</html>